﻿using System.Collections.Generic;
using HMIS.FrameWork.DomainBase;
using HMIS.Infrastructure.Core.Authority;
using HMIS.Infrastructure.Core.Authority.Services;
using HMIS.Infrastructure.Core.Repositories;

namespace HMIS.Infrastructure.Facade.Authority.Impl
{
    public class ActionPermissionFacadeImpl : IActionPermissionFacade
    {
        private readonly IActionPermissionRepository ActionPermissionRepository;
        private readonly IActionPermissionService ActionPermissionService;
        public ActionPermissionFacadeImpl(IActionPermissionRepository ActionPermissionRepository, IActionPermissionService ActionPermissionService)
        {
            this.ActionPermissionRepository = ActionPermissionRepository;
            this.ActionPermissionService = ActionPermissionService;
        }

        #region IActionPermissionFacade 成员

        public IList<ActionPermission> GetPlistAll(int start, int limit, string sort, string dir, List<DataFilter> filters, out long total)
        {
            return ActionPermissionRepository.GetPlistAll(start, limit, sort, dir, filters, out total);
        }

        public IList<ActionPermission> QueryActionPlist(string query, int start, int limit, out long total)
        {
            return ActionPermissionService.QueryActionPlist(query, start, limit, out total);
        }

        public void SaveOrUpdate(ActionPermission entity)
        {
            ActionPermissionRepository.SaveOrUpdate(entity);
        }

        public ActionPermission LoadActionPermission(string id)
        {
            return ActionPermissionRepository.Load(id);
        }

        public ActionPermission GetActionPermission(string id)
        {
            return ActionPermissionRepository.Get(id);
        }

        public bool IsFieldExistForActionPermission(string fieldName, string fieldValue, string id, string controllerName)
        {
            return ActionPermissionRepository.IsFieldExist(fieldName, fieldValue, id, controllerName);
        }

        public void DeleteActionPermission(string id)
        {
            ActionPermissionRepository.Delete(id);
        }

        public IList<ActionPermission> GetActionPermissionListByRoleId(string roleId)
        {
            return ActionPermissionRepository.GetListByRoleId(roleId);
        }

        #endregion
    }
}
